﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Fuse8.ContentManagementFramework.Domain;
using Fuse8.ContentManagementFramework.Domain.Commands.CommandParameters;
using Fuse8.ContentManagementFramework.Domain.Commands;
using Fuse8.DomainFramework.Common.Locator;

namespace Fuse8.ContentManagementFramework.BizFacade.Services
{
        public class CmsSiteService : CmsBusinessService<CmsSite>
        {
            public virtual IEnumerable<CmsSite> FindAvailableByUser(CmsUser user)
            {
                var command = DependencyServiceLocator.Current.GetInstance<CmsSiteSelectForUserCommand>();

                var commandParameter = new CmsSiteSelectForUserCommandParameter();

                commandParameter.UserId = user.Id;

                command.ConfigureCommand(commandParameter);

                return this.Find(command);
            }

            public virtual CmsSite FindByHostname (string hostname)
            {
                var command = DependencyServiceLocator.Current.GetInstance<CmsSiteSelectForHostnameCommand>();

                var commandParameter = new CmsSiteSelectForHostnameCommandParameter {Hostname = hostname};

                command.ConfigureCommand(commandParameter);

                return this.FindOne(command);
            }
        }
}
